<template>
<el-tooltip effect="dark" content="待接收的分享文件" placement="bottom-end">
    <el-badge :value="msg_number">
        <div class="share_msg_bt" @click="on_accept">
            <i class="el-icon-s-comment"></i>
        </div>
    </el-badge>
</el-tooltip>
</template>
<script>
export default { //待接收分享文件点击按钮
    name:"Share_msg_bt",
    data(){
        return{
            msg_number:0,
            lock:true,
        };
    },
    created(){
        this.get_msg_number();
        setInterval(()=>{ //轮询获取待接收的文件数目
            if(this.lock){
                //this.get_msg_number();
            }
        },7000);
    },
    methods:{
        on_accept(){ //跳转到分享待接收页面
            this.$router.push('/share');
        },
        get_msg_number(){ //获取待接收文件数量
            this.lock = false;
            this.$axios.json_post('/shared/receptCount').then(({data})=>{
                this.msg_number = data;
            }).finally(()=>{
                this.lock = true;
            }).catch(()=>{
                return;
            });
        },
    },
}
</script>
<style lang="scss" scoped>
.share_msg_bt{
    width: 100%;
    height: 100%;
    background-color: #eaeaea72;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 25px;
    line-height: 100%;
    box-sizing: border-box;
    border-radius: 2px;
    cursor: pointer;
}
</style>